import os
from dotenv import load_dotenv
from processors.video_processor import process_chapter

# 加载环境变量
load_dotenv()

def main():
    # 从环境变量获取API密钥
    api_key = os.environ.get("ARK_API_KEY")
    if not api_key:
        print("❌ 错误: 未设置 ARK_API_KEY 环境变量")
        return
    
    chapter_content = """"Baby Annoucement

Uriel
“That was terrible!” I plopped my head on my gigantic fluffy heart pillow. A hot tear ran down my puffy face. “I can’t even finish the movie, if that poor little thing has to live on like that.” Taking the remote, I stopped the movie and tossed remote to the other side of the room. “That poor little deer lost his mom and had to go live with his really serious dad. I’m not finishing that. He looked waaay too grumpy to be a happy ending and I am all about happy endings. 
Sliding off the bed in my white nightgown, I glance at the clock to see if I could come out of my room. Mom and Dad have been waiting on the stork for a new baby brother. They said I wasn’t allowed to come downstairs all night long.
The stork works the night shift, apparently. 
That was so hard too, because I like my midnight sneaky snacks. I had a fun little hiding spot right in the kitchen that Mom doesn’t even know about. Best part of all, it keeps popping up with new candy all the time. It’s like magic, and magic is really awesome. Especially when Dad shows me his armor, he just wills it just like my wings and BOOM right on his body. He has this amazing sword, and it’s so sharp I’m not allowed to touch it. 
Mom gets super cranky when he shows me his battle armor. She gets cranky, like a lot. 
Dad likes to watch me when I’m in the kitchen. He has this little smile on his face when I get near my hiding spot, so I can’t go near it when he is awake. He knows I have a secret stash, but I would never tell him where it is, I might have to change it really soon so he doesn’t steal it. 
I pranced downstairs, not taking notice of my wings banking the stairwell all the way down. I squeaked, covering my mouth with both my hands. Mom hates it when I don’t put my wings away when I’m in the house. It wasn’t my fault they had a mind of their own. They just flutter when I get real happy and then when I get all sad, they droop like those cute little killer whales’ fins they keep in captivity.
Those poor whales.
Willing my wings back into my body, I tiptoed down the stairs. My parents’ room was on the main level of the house, because Dad has to leave suddenly sometimes. He’s an archangel, the coolest job, and he has to listen to whatever his boss, Zeus, says. 
Tapping by my parents’ room, I scooted into the large kitchen. Mom had all the best cooking equipment. She loved to cook and her favorite thing to make was the double chocolate cake with strawberry drizzle. It’s my favorite, and she makes it when I argue too much about wanting to go outside.
Rubbing my hands together, doing my little booty shake before I opened the big box of prunes that secretly held my stash, the doorbell went off. My box of-not prunes went flying in the air, landing in the sink. 
Gasping, I shrunk down to the floor. The floor was pristine white, just like everything else in this house except all the greenery Mom liked. Do you know how long it takes to water all the plants in the morning? It takes forever!
The doorbell rang again, but I stayed silent. That was the rule, I could not leave the house without Mom or Dad, can’t answer the door and can’t have friends, which made me sad. They said the world was crazy out there with so much evil that I couldn’t imagine. They said it was worse when Hans tricked Ana, but now I’m thinking maybe it was worse than that little deer who just lost his mom.
That poor baby deer!
But I had a wish, and that wish was for me to step out of here alone. Mom always made me wear cloaks covering my face and no one ever noticed me! I didn’t like wearing a cloak; I wanted to feel the sunshine, but she said I could get skin cancer. I didn’t know gods got skin cancer, but apparently they do.
When I first learned how to fly, she made me go out at night with Dad. It was so dark I kept flying into poles and I had a black eye for an entire hour! I cried and cried until Dad argued with Mom about how silly it was for me to fly at night, especially when it was hard to see.
For a moment, her eyes filled with regret until her irrational feelings flooded over her again. “There are too many dangers. Better a black eye than some demon to take her down to the pits of Tartarus.”
I didn’t know what any of that was, but if it was worse than a black eye, I didn’t want it. Cause it really hurt.
The doorbell rang again, shaking me from my thoughts. Finally, a letter fell through the slots. It was slightly aflame, but still the paper had yet to burn.
Oh goodie, I more magic!
I crawled over, peeking through the mail slot to make sure the mailman was gone. He doesn’t know me, but I know him. The neighbors’ Pegasus begs him for sugar cubes every day and when he forgets, the pegasus bites him right on the tushie! I snorted back a laugh. It was a funny animal. When Mom and Dad aren’t looking, I throw my carrots and celery out the window and it neighs happily.
I’m glad someone like vegetables because I certainly didn’t. 
I really wanted a pet just like a pegasus but mom said no, “they poop all over the house.”
Returning to the letter still aflame, touching it a few times to make sure it would burn my freshly painted pearl nails, I flipped it over.
“To the Soul Bonded Couple Goddess Hera and Arch Angel Michael,” it was in beautiful calligraphy lettering that shined when the light would hit it at a certain angle. Mom and Dad always let me open the mail. It was like opening presents on Christmas except this was just a letter, so there weren’t fun presents inside.
Ripping it open, the fire envelope fell to the floor, turning to a light powder of ash before finally disappearing. “That’s amazing,” I whispered, my foot swishing the floor to feel for remanents of the ash. Reading its contents, there was a black stenciled drawing of a massive palace, with a three-headed dog on the letterhead. “From the Delighted Parents of Hades, God of the Underworld and Parisa Goddess of Empathy and Bonding.”
“Wooooah,” I held up the letter to the light. The dog was simply adorable, and the palace was the darkest thing I had ever seen. Black wasn’t around the Celestial Kingdom and this, this was the darkest thing I had ever seen. My finger traced the slightly raised lines.
“Ugh, focus.”
As I read, I found it to be a baby announcement and party. They had a baby! Babies were so cute but I had never seen one up close and I have never been to a party! Would Mom let me go? If it was up to Dad, he would let me do lots of things, but Dad tells me a lot that he is ‘whipped’ or his ‘balls are on the fridge.’ I never found a whip in the house and there were no balls on top of the fridge, so I don’t know what he was talking about.
Anyway, I could do two things at once if Mom was in a good mood and she was always in a good mood in the mornings. Maybe we can all go! I ran to Mom and Dad’s bedroom door, that I am not allowed to open. I have to knock really loud so they can hear because sometimes they wrestle.
Mom’s really loud when she wrestles. Sometimes I have to turn up a movie really loud.
Knocking three times, I heard Dad’s voice. “What?” he sounded out of breath. “Sorry, did I wake you up?”
“No, I’ve been up,” he choked back a labored laugh.
“Oh, Okay,” I pulled at the hem of my short nightgown, fiddling with it, still holding the letter in my other hand. “I was wondering,” I muttered.
“Yes!!” My Mom squealed. My eyes brightened. Did she read my mind?
“So can I just go- “
“YES! YES,” she moaned loudly as I heard a thud on the other side of the door. Sounded like Mom was winning. I jumped up and down squealing, my wings flying out of my body too quickly, causing a small vase to land on the floor.
Whoops, I’ll clean that later. 
“Yippie!” Running up the stairs. I changed into my prettiest finger tip length white dress because Mom said I looked best in white. I found some baby’s breath flowers, making them into a small crown to put on my head. The white flowers really popped against my dark hair. Dashing a bit of glitter around my cheeks and checking my face to make sure it was clean, I ran back down the stairs, leaving the mess I made on the floor.
Checking myself in the mirror one last time, fixing the crazy curl that liked to curve around my neck, I took a large breath. For the first time, I was going to feel the sun on my skin and not the rough texture of the stupid cape. Mom didn’t bring it up, and neither will I! My smile brightened, opening the door and to the brightly lit sky.
“Yes,” I sighed heavily, shutting the door and taking flight to the nearest portal to the Underworld.
Lucifer
“Where in Tartarus have you been?” I shut the door to my bedroom, my father sitting on the bed with a scowl on his face. “Do you know what time it is, Lucifer? It’s six in the damn morning and you were gone all night. Were you screwing some slutty demon?” 
I growled out, my hands turning black with cracks of red magma between them. “Don’t fucking start with me old man,” my large purple flames engulfed my hands, ready to fight against my father. His face instantly fell, his shoulders shrugging, sitting back on the bed. 
“I shouldn’’t have raised my voice,” his hand rubbed his mouth. “Your Mother is worried, and in turn, it makes me worry. Where have you been?" 
Willing my hands clean, I walked to the wardrobe, stripping off my bloody clothes and wrapping a towel around my waist. Father patiently waited, knowing I was calming the fire inside my belly. My anger was only getting worse as the days passed, my own Father having to control his just to make sure I don’t go out of control. If I did, who knows what would happen to my family if I went nuclear? 
My Father shouldn’t have to do that, he should have to calm his son, he should be able to punish me to teach me a lesson. I rubbed my face with both hands, sitting in my desk chair. “Sorry, Father.” Father turned to me, his eyes softening. The internal battle with in me was a losing one, and we both knew that. He knew how serious this had become and we both had started preparations.
“I won’t be able to control the rage much longer. It’s best we implement the plan we discussed.” Father shook his head, pulling his freshly styled hair. 
“No, I refuse to believe it has come to this. You are still so young. You have to fight it.” 
Abruptly standing from my chair, my black wings flew out of my body, the fire tickling the tips of the feathers grew brighter. “You don’t understand, I can’t! I thirst for blood, I thirst to destroy everything in my path. Who knows when I will fail and hurt the innocent? What if I went to Earth? What if I start the Apocalypse!”
“That is a human tale, its not real,” he calmly stated. 
“Maybe it is!” I chuckled manically. “Maybe it is I who is to start it and that is why you will lock me in Tartus next to your father!”"
"""
    result = process_chapter(chapter_content, api_key)

    print("\n" + "=" * 60)
    print("🎬 视频生成完成!")
    print("=" * 60)

    if result["success"]:
        print(f"✅ 成功生成视频")
        print(f"📁 输出文件夹: {result['output_dir']}")
        print(f"🕐 生成时间戳: {result['timestamp']}")
        print(f"📽️ 最终视频: {result.get('output_file', '单段视频')}")
        print(f"🎞️ 视频段数: {result['segments_count']}")
        print(f"📝 段落数: {result['paragraphs_count']}")
    else:
        print(f"❌ 生成失败: {result['error']}")
        print(f"📁 输出文件夹: {result.get('output_dir', '未创建')}")

    print("=" * 60)


if __name__ == "__main__":
    main()
